package com.mtsmda.collection;

import java.util.ArrayDeque;
import java.util.Deque;

public class DequeDemo {

	public static void main(String[] args) {
		arrayDequeDemo();
	}
	
	/**
	 * <p>
	 * Resizable-array implementation of the Deque interface. Array deques have
	 * no capacity restrictions; they grow as necessary to support usage. They
	 * are not thread-safe; in the absence of external synchronization, they do
	 * not support concurrent access by multiple threads. Null elements are
	 * prohibited. This class is likely to be faster than Stack when used as a
	 * stack, and faster than LinkedList when used as a queue.
	 * </p>
	 * */
	private static void arrayDequeDemo() {
		Deque<String> arrayDeque = new ArrayDeque<>();
		System.out.println(arrayDeque.add(new String("Greciya")));
		System.out.println(arrayDeque.add(new String("Italiya")));
		System.out.println(arrayDeque.add(new String("Germaniya")));
		arrayDeque.addFirst(new String("Ispaniya"));
		arrayDeque.offerFirst(new String("Portugaliya"));

		/* System.out.println(arrayDeque.add(null)); */

		System.out.println(arrayDeque.size());

		System.out.println();

		for (String s : arrayDeque) {
			System.out.println(s);
		}
	}

}